<!DOCTYPE html>
<html lang="en">
<head>

	<meta charset="utf-8">
    <title>商品管理|添加商品</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    
    <!-- Le styles -->
    <link href="/cssadmin/bootstrap.css" rel="stylesheet">
    <link href="/cssadmin/font-awesome.css" rel="stylesheet">
    <link href="/cssadmin/admin.css" rel="stylesheet">
    <script src="/jsadmin/jquery.min.js"></script>
    <!--编辑器-->
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
	    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

</head>    
<body>

<div class="container">
	<div class="row">
		<div class="span2">
		<div class="main-left-col">
			<h1><i class="icon-shopping-cart icon-large"></i> Admin</h1>
			<ul class="side-nav">
				<li>
					<a href="{{url('admins/index')}}"><i class="icon-home"></i> 管理中心</a>
				</li>
				<li class="dropdown active">
					<a class="dropdown-toggle" data-toggle="collapse" data-target="#website-dropdown" href="#"><i class="icon-sitemap"></i> 商品管理 <b class="caret"></b></a>
					<ul id="website-dropdown">
						<li><a href="{{url('admins/glist')}}">商品列表</a></li>
						<li><a href="{{url('admins/clist')}}">商品分类</a></li>
						<li class="active"><a href="#">添加商品</a></li>
						<li><a href="{{url('admins/cadd')}}">添加分类</a></li>
						<li><a href="{{url('admins/grealdel')}}">回收站</a></li>
					</ul>
				</li>
				<li class="dropdown">
					<a class="dropdown-toggle" data-toggle="collapse" data-target="#store-dropdown" href="#"><i class="icon-shopping-cart"></i> 订单管理 <b class="caret"></b></a>
					<ul id="store-dropdown" class="collapse">
						<li><a href="listing.html">订单列表</a></li>
						<li><a href="orders.html">已发货订单</a></li>
						<li><a href="listing.html">待处理订单</a></li>
						<li><a href="listing.html">查询订单</a></li>
					</ul>
				</li>
				<li class="dropdown">
					<a class="dropdown-toggle" data-toggle="collapse" data-target="#reports-dropdown" href="#"><i class="icon-signal"></i> 会员管理 <b class="caret"></b></a>
					<ul id="reports-dropdown" class="collapse">
						<li><a href="report.html">会员列表</a></li>
					</ul>
				</li>
			</ul>
		</div> <!-- end main-left-col -->
	</div> <!-- end span2 -->
	

	<div class="span10">
		<div class="main-area dashboard">
		<?php echo $tishiinfo;?>
		<div class="row">
			<div class="span10">
				<a href="#" class="btn btn-info">已上架商品</a>
				<a href="{{url('admins/glist')}}" class="btn btn-danger">仓库中的商品</a>
				<a href="{{url('admins/gadd')}}" class="btn btn-success">添加新商品</a>
				<a href="{{url('admins/cadd')}}" class="btn btn-primary">增加新分类</a>
				<a href="#" class="btn btn-default">回收站</a>
			</div>
			<div class="span10">

			<div class="slate">
			<div class="page-header">
				<h2>添加新商品:</h2>
			<form action="{{url('admins/gadd')}}" method="post" class="form-horizontal" enctype="multipart/form-data" id="form_id">
				<div class="control-group">
					<label class="control-label" for="goodsname">商品名称:</label>
				    <div class="controls">
				      	<input type="text" id="goodsname" placeholder="填入商品名称(必填)" name="goods_name">
				    </div>
				</div>
				<div class="control-group">
					<label class="control-label" for="goods_sn">商品货号:</label>
					<div class="controls">
						<input type="text" id="goods_sn" placeholder="不填则自动生成" name="goods_sn">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="goodskucun">商品库存:</label>
					<div class="controls">
						<input type="number" id="goodskucun" name="goods_number" placeholder="填入商品库存(必填)" >
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="catparent">商品分类:</label>
				    <div class="controls">
				      	<select id="catparent" name="cat_id">
							@foreach($catlist as $cat)
								<option class="disabled1" value="{{$cat['cat_id']}}">{{$cat['cat_name']}}</option>
								@foreach($cat['sbu'] as $caterzi)
									@if($cat['cat_id'] == $caterzi['parent_id'])
										<option value="{{$caterzi['cat_id']}}">|---{{$caterzi['cat_name']}}</option>
									@endif
								@endforeach
							@endforeach
						</select>
						<script>
							$(document).ready(function(){
								$('.disabled1').prop('disabled',true);
							});
						</script>
				    </div>
				</div>
				<div class="control-group">
					<label class="control-label" for="goodsnumber">本店售价:</label>
				    <div class="controls">
				      	<input type="number" id="goodsnumber" placeholder="(必填)"name="shop_price">
				    </div>
				</div>
				<div class="control-group">
					<label class="control-label" for="goodsnumber">市场售价:</label>
					<div class="controls">
						<input type="number" id="goodsnumber" placeholder="(必填)"name="market_price">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="catparent">商品详情:</label>
				    <div class="controls">
				      	<textarea rows="3" name="content"></textarea>
				    </div>
				</div>
				<div class="control-group">
					<label class="control-label" for="goodpic">商品图片:</label>
				    <div class="controls">
				      	<input type="file" id="goodpic" placeholder="" name="goodpic">
				    </div>
				</div>
				<div class="control-group">
					<label class="control-label" for="goodsname">图片预览:</label>
				    <div class="controls">
				      	<img src="/img/T04.jpg" class="img-rounded" style="width:30%;" id="showpic">
				    </div>
				</div>
				<script>
					/**
					 * Ajax上传图片   获取到保存的地址存入hidden框中
					 */
					$(document).ready(function(){
						$('#goodpic').change(function(){
							var fom = document.getElementById('form_id');
							var fmdata = new FormData(fom);
							var xhr = new XMLHttpRequest();
							xhr.onreadystatechange = function(){
								if(this.readyState == 4){
									var rs = this.responseText;
									$('#showpic').attr('src',rs);
									$('#pic').val(rs);
								}
							}
							xhr.open('post','{{url('admins/img')}}',false);
							xhr.send(fmdata);
						});
					});
				</script>
				{!! csrf_field() !!}
				<input type="hidden" name="goodspic" id="pic">
				<div class="control-group">
					<label class="control-label" ></label>
				    <div class="controls">
				      	<button class="btn btn-success" type="submit">提交</button>
				      	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				      	<button class="btn btn-danger" type="reset">重置</button>
				    </div>
				</div>
			</form>
		</div>
	</div>
</div>	
	<div class="row">
		<div class="span10 footer">
			<p>&copy; Web2016</p>
		</div>
	</div>
</div>
	
	</div> <!-- end span10 -->
		
	</div> <!-- end row -->
		
</div> <!-- end container -->

<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->

<script src="/jsadmin/bootstrap.js"></script>
</body>
</html>